﻿namespace XjjXmm.CodeGenerator
{
    public class NetModelGeneratorStrangy : NetBaseGeneratorStrangy
    {
        protected override string GetTableName(TableInfo table)
        {
            var names = table.DbName.ToLower().Split('_');

            var res = "";
            foreach (var name in names)
            {
                res += name.Substring(0, 1).ToUpper() + name.Substring(1);
            }

            return res + "Model";
        }
    }

    public class NetIServiceGeneratorStrangy : NetBaseGeneratorStrangy
    {
        public override dynamic GetTableModel(TableInfo table)
        {
            // table.PropertyName = GetTableName(table);

            return new
            {
                DbName = table.DbName,
                PropertyName = GetTableName(table),
                Description = table.Description,
                EntityName = GetEntityName(table),
                ModelName = GetModelName(table),
            };
        }

        protected override string GetTableName(TableInfo table)
        {
            var res = base.ConverCamlName(table.DbName);

            return "I" + res + "Service";
        }

        protected virtual string GetEntityName(TableInfo table)
        {
            var res = base.ConverCamlName(table.DbName);

            return res + "Entity";
        }

        protected virtual string GetModelName(TableInfo table)
        {
            var res = base.ConverCamlName(table.DbName);

            return res + "Model";
        }

    }

    public class NetServiceGeneratorStrangy : NetIServiceGeneratorStrangy
    {
        protected override string GetTableName(TableInfo table)
        {
            var res = base.ConverCamlName(table.DbName);

            return res + "Service";
        }
    }

    public class NetMapperGeneratorStrangy : NetIServiceGeneratorStrangy
    {
        protected override string GetTableName(TableInfo table)
        {
            var res = base.ConverCamlName(table.DbName);

            return res + "MapperConfig";
        }
    }
}
